package com.zq.it.action;


import com.zq.it.tool.Constant;
import com.zq.it.tool.SecurityCode;
import com.zq.it.tool.SecurityImage;
import java.io.ByteArrayInputStream;
import javax.servlet.http.HttpSession;

 
 /**
11  * 提供图片验证码
12  * @version 1.0 2012/08/22
13  * @author dongliyang
14  */
 
 @SuppressWarnings("serial")
 public class SecurityCodeImageAction extends BaseAction{
  
     //图片流
     private ByteArrayInputStream imageStream; 
     private HttpSession session =null;   
     
    public ByteArrayInputStream getImageStream(){
         return imageStream;
     }
 
     public void setImageStream(ByteArrayInputStream imageStream){
    	 
    	
         this.imageStream = imageStream;
     }
      
     public String sendSecurityCode() { 
    	 
         //获取默认难度和长度的验证码
         String securityCode = SecurityCode.getSecurityCode();         
         imageStream = SecurityImage.getImageAsInputStream(securityCode);  
         getRequest().getSession().setAttribute(Constant.SECURITY_CODE, securityCode);
         return SUCCESS;       
     }
 }
